<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>通过连接另一个数组的子数组得到一个数组</title>
</head>
<body>
  <script>
    function fn(arr, nums) {
      let str = nums.join('_'), q = 0
      for (let i = 0; i < arr.length; ++i) {
        let s1 = arr[i].join('_'), s2 = str.slice(q)
        let p = s2.indexOf(s1)
        // 注意后面的条件：除非p为相对于str的索引0，否则前一个字符必须为 _
        // 意思就是避免 `[2, 1]` 匹配成功 `[12, 1]`
        if (p === -1 || (s2[p - 1] && s2[p - 1] !== '_')) return false
        q += (p + s1.length)
      }
      return true
    }
    console.log(fn([[1, -1, -1], [3, -2, 0]], [1, -1, 0, 1, -1, -1, 3, -2, 0]))
  </script>
</body>
</html>